import { ElMessage } from "element-plus"
import zxcvbn from "zxcvbn"

//验证密码强度
export const verifyPasswordStrength = (password: string) => {
    const score = zxcvbn(password).score
    if (score < 2) {
        ElMessage.warning('密码强度较弱，建议使用字母、数字和符号组合')
        return false
    }
    return true
}

//验证邮箱格式
export const verifyEmailFormat = (email: string) => {
    const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
    return emailRegex.test(email)
}

//验证账号格式
export const verifyAccountFormat = (account: string) => {
    const accountRegex = /^[a-zA-Z0-9]+$/
    return accountRegex.test(account)
}
